<template>
    <div class="login-container">
      <div class="login-bg"></div>
      <el-card class="login-card">
        <div class="login-header">
          <h2 class="login-title">欢迎登录</h2>
          <p class="login-subtitle">AI 智能助手平台</p>
        </div>
        <el-form :model="loginForm" :rules="rules" ref="loginFormRef">
          <el-form-item prop="phone">
            <el-input
              v-model="loginForm.phone"
              placeholder="请输入手机号"
              size="large"
              :prefix-icon="UserFilled"
            />
          </el-form-item>
          <el-form-item prop="password">
            <el-input
              v-model="loginForm.password"
              type="password"
              placeholder="请输入密码"
              size="large"
              :prefix-icon="Lock"
              show-password
            />
          </el-form-item>
          <el-button 
            type="primary" 
            class="login-btn" 
            @click="handleLogin"
            :loading="loading"
            size="large"
            round
          >
            登 录
          </el-button>
        </el-form>
        <!-- <div class="login-footer">
          <el-divider>其他登录方式</el-divider>
          <div class="social-login">
            <el-icon :size="24"><Avatar /></el-icon>
            <el-icon :size="24"><Message /></el-icon>
            <el-icon :size="24"><Iphone /></el-icon>
          </div>
        </div> -->
      </el-card>
    </div>
  </template>
<script>
// import {   Avatar, Message, Iphone } from '@element-plus/icons-vue';
export default {
    name: 'LoginPage',
    // components: {  Avatar, Message, Iphone },
  data() {
    const validatePhone = (rule, value, callback) => {
      if (!/^1[3-9]\d{9}$/.test(value)) {
        callback(new Error('请输入正确的手机号'));
      } else {
        callback();
      }
    };
    
    return {
      loading: false,
      loginForm: {
        phone: '',
        password: ''
      },
      rules: {
        phone: [
          { required: true, message: '请输入手机号', trigger: 'blur' },
          { validator: validatePhone, trigger: 'blur' }
        ],
        password: [
          { required: true, message: '请输入密码', trigger: 'blur' },
          { min: 6, message: '密码长度至少6位', trigger: 'blur' }
        ]
      }
    };
  },
  methods: {
    handleLogin() {
      this.$refs.loginFormRef.validate(valid => {
        if (valid) {
          this.loading = true;
          // 模拟登录请求
          setTimeout(() => {
            this.loading = false;
            this.$router.push('/');
          }, 1000);
        }
      });
    }
  }
};
</script>

<style scoped>
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  position: relative;
  overflow: hidden;
}
.login-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #409eff 0%, #36c6d9 100%);
  z-index: 1;
}
.login-card {
  width: 420px;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  z-index: 2;
  background: rgba(255, 255, 255, 0.95);
}
.login-header {
  text-align: center;
  margin-bottom: 40px;
}
.login-title {
  font-size: 24px;
  font-weight: 500;
  color: #303133;
  margin-bottom: 8px;
}
.login-subtitle {
  font-size: 14px;
  color: #909399;
}
.login-btn {
  width: 100%;
  margin-top: 20px;
  letter-spacing: 2px;
}
.login-footer {
  margin-top: 30px;
}
.social-login {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 15px;
}
.social-login .el-icon {
  color: #606266;
  cursor: pointer;
  transition: all 0.3s;
}
.social-login .el-icon:hover {
  color: #409eff;
  transform: translateY(-3px);
}

:deep(.el-input__wrapper) {
  border-radius: 8px;
  padding: 5px 15px;
}
</style>